package org.zoomdev.zoom.web.rendering;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public final class TemplateRenderingManager {

    private final Map<String, Rendering> pool = new ConcurrentHashMap<String, Rendering>();

    /**
     * 增加一个模版渲染器 后缀不含有.  ,如   TemplateRenderingManager.add("html",myRendering);
     *
     * @param ext
     * @param rendering
     */

    public void add(String ext, Rendering rendering) {
        assert (ext != null);
        assert (rendering != null);
        assert (!ext.startsWith("."));
        pool.put(ext, rendering);
    }


    /**
     * 根据后缀获取模版渲染器，后缀不含有.  ,如   TemplateRenderingManager.getRendering("html");
     *
     * @param ext
     * @return
     */
    public Rendering getRendering(String ext) {
        assert (ext != null);
        assert (!ext.startsWith("."));
        return pool.get(ext);
    }
}
